using Microsoft.AspNetCore.Mvc;
using WebApi.Models;
using WebApi.Services;

namespace WebApi.Controllers;

[ApiController]
[Route("[controller]")]
public class ProjectsController : ControllerBase
{
    private readonly IProjectService _projectService;
    private readonly ILogger<ProjectsController> _logger;

    public ProjectsController(IProjectService projectService, ILogger<ProjectsController> logger)
    {
        _projectService = projectService;
        _logger = logger;
    }
    
    [HttpGet]
    public async Task<IEnumerable<ProjectModel>> Get()
    {
        return await _projectService.GetAllProjects();
    }


    [HttpPost]
    public async Task<ActionResult<int>>  Post([FromBody] List<UserProjectModel> models)
    {
        return await _projectService.InsertUserProjectModels(models);
    }
}